<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>计算器练习</title>
	</head>
	<body>
		<div id="app">
			<!-- 要求:输入完B之后,回车键触发计算 加法操作 -->
			数据A: <input type="text" v-model="num1" />
			数据B: <input type="text" v-model="num2" @keyup.enter="addNum" />
			总数: <span v-text="count"></span>
		</div>
		<script src="../js/vue.js"></script>
		<script>
			const app = new Vue({
				el: "#app",
				data: {
					num1: '',
					num2: '',
					count: ''
				},		
				methods: {
					addNum() {
						//parseInt() 将字符串转化为数值
						this.count =
							parseInt(this.num1) + parseInt(this.num2)
					}
				}
			})
		</script>
	</body>
</html>
